home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / lmemcmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  632 b   |  40 lines

  1. #ifdef __GNUC__
  2. #ifdef __MSHORT__
  3. #include "lib.h"
  4.  
  5. #ifndef CHARBITS
  6. #    define    UNSCHAR(c)    ((unsigned char)(c))
  7. #    define  uchar        unsigned char
  8. #else
  9. #    define    UNSCHAR(c)    ((c)&CHARBITS)
  10. #    define  uchar        char
  11. #endif
  12.  
  13. /*
  14.  * memcmp - compare bytes
  15.  */
  16.  
  17. int                /* <0, == 0, >0 */
  18. lmemcmp(s1, s2, size)
  19. _CONST _VOIDSTAR s1;
  20. _CONST _VOIDSTAR s2;
  21. long size;
  22. {
  23.     register _CONST char *scan1;
  24.     register _CONST char *scan2;
  25.     register long n;
  26.  
  27.     scan1 = s1;
  28.     scan2 = s2;
  29.     for (n = size; n > 0; n--)
  30.         if (*scan1 == *scan2) {
  31.             scan1++;
  32.             scan2++;
  33.         } else
  34.             return(*scan1 - *scan2);
  35.  
  36.     return(0);
  37. }
  38. #endif /* __MSHORT__ */
  39. #endif /* __GNUC__   */
  40.